<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<!--
Manually edited, please keep neatly wrapped!
$Id: faq_yv12.htm,v 1.8 2009/09/12 20:57:20 wilbertd Exp $ 
-->
   <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
   <title> Frequently Asked Questions - YV12 </title>
<style type=text/css></style>
   <link rel="stylesheet" type="text/css" href="../avisynth.css">
</head>
<body>

<h1>AviSynth FAQ - The color format YV12 and related
processing and encoding issues</h1>

<h2>Contents</h2>
<ol>
  <li>
<a href="#YV12">What is YV12?</a></li>
  <li><a href="#download_stable_avs">Where can I download the latest stable
  AviSynth version which supports YV12?</a></li>
  <li><a href="#download_DGIndex">Where can I download the DGIndex/DGDecode plugin,
  which supports YV12, to import MPEG-1/MPEG-2/TS/PVA in AviSynth&nbsp;?</a></li>
  <li><a href="#encoders">Which encoding programs support YV12?</a></li>
  <li><a href="#encoders2">How do I use v2.5x if the encoding programs can't handle
  YV12 (like TMPGEnc or CCE SP)?</a></li>
  <li><a href="#advantages">What will be the main advantages of processing in YV12?</a></li>
  <li><a href="#VirtualDub">How do I use VirtualDub/VirtualDubMod such that there
  are no unnecessary color conversions?</a></li>
  <li><a href="#internal_filters">Which internal filters support YV12?</a></li>
  <li><a href="#external_plugins">Which external plugins support YV12?</a></li>
  <li><a href="#disadvantages">Are there any disadvantages of processing in YV12?</a></li>
  <li><a href="#colorspace">How do I know which colorspace I'm using at a given
  place in my script?</a></li>
  <li><a href="#colors_swapped">The colors are swapped when my I load a DivX file in
  AviSynth v2.5?</a></li>
  <li><a href="#green_line">I got a green (or colored
    line) at the left or at the right of the clip, how do I get rid of it?</a></li>
  <li><a href="#error_message">I installed AviSynth v2.5 and get the following
  error message: "Couldn't locate decompressor for format 'YV12'
  (unknown)."?</a></li>
  <li><a href="#black_screen">I installed AviSynth v2.5 and DivX5 (or one of the
  latest Xvid builds of Koepi), all I got is a black screen when opening my avs
  in VirtualDub/VirtualDubMod/MPEG-2 encoder?</a></li>
  <li><a href="#YV12_codecs">Are there any lossless YV12 codecs, which I can use
  for capturing for example?</a></li>
  <li><a href="#links">Some important links</a></li>
</ol>

<h3><a name="YV12"></a>What is YV12?</h3>

<p>These are several different ways to represent colors. For example: YUV and
  RGB colorspace. In YUV colorspace there is one component that represent
  lightness (luma) and two other components that represent color (chroma). As
  long as the luma is conveyed with full detail, detail in the chroma components
  can be reduced by subsampling (filtering, or averaging) which can be done in
  several ways (thus there are multiple formats for storing a picture in YUV
  colorspace). YV12 is such a format (where chroma is shared in every 2x2 pixel
  block) that is supported by AviSynth. Many important codecs stored the video in
  YV12: MPEG-4 (x264, XviD, DivX and many others), MPEG-2 on DVDs, MPEG-1 and
  MJPEG.

<h3><a name="download_stable_avs"></a>Where can I download the latest stable
  AviSynth version which supports YV12?</h3>

<p>"AviSynth v2.5<font color="#FF0000">7</font>&quot; (and more recent versions) can be downloaded
  <a href="http://sourceforge.net/project/showfiles.php?group_id=57023">here</a>.

<h3><a name="download_DGIndex"></a>Where can I download the DGIndex/DGDecode
  plugin, which supports YV12, to import MPEG-1/MPEG-2/TS/PVA in
  AviSynth&nbsp;?</h3>
<p>The latest DGIndex/DGDecode combo can be downloaded
  <a href="http://neuron2.net/dgmpgdec/dgmpgdec.html">here</a>.

<h3><a name="encoders"></a>Which encoding programs support YV12?</h3>

<p>The regular builds of Virtualdub (by Avery Lee) have YV12 support in fast
  recompress mode since v1.5.6.  There are also two another options for
  encoding to DivX/XviD:<br>

  There is a modified version (called VirtualdubMod) which has YV12 support:
  This modification (by pulco-citron, Suiryc and Belgabor) has OGM and
  AVS-preview support. It can be downloaded from
  <a href="http://sourceforge.net/projects/virtualdubmod/virtualdubmod.html">here</a>.
  In order to use the YV12 support (without doing any color conversions) you
  have to load your AVI in VirtualdubMod and select "fast recompress".<br>

  For easy (and fast) YV12 support, you can also try out the command line
  utility <a href="http://www.avs2avi.org">AVS2AVI</a> - compresses video from
  an AviSynth script using any VFW codec, see also
  <a href="http://forum.doom9.org/showthread.php?t=71493">here</a>.<br>

  The MPEG-1/MPEG-2 encoders <a href="http://www.bitburners.com/HC_Encoder/"> HC</a>
  and <a href="http://www.bitburners.com/QuEnc/"> QuEnc</a> also support (and
  even require) YV12.

<h3><a name="encoders2"></a>How do I use v2.5x if the encoding programs can't
  handle YV12 (like TMPGEnc or CCE SP)?</h3>

<p>Using TMPGEnc you have to add the line &quot;<a
  href="corefilters/convert.htm">ConvertToRGB24</a>&quot; (with proper
  "interlaced" option) to your script, and for CCE SP you need to add the line
  &quot;<a href="corefilters/convert.htm">ConvertToYUY2</a>&quot; to your
  script, since Windows has no internal YV12 decompressor.

<p>You can also install some <a href="#error_message">YV12 decompressor (codec)</a>
  which will decompress the YV12-AVI for you when loading the avi in
  TMPGEnc or CCE SP.

<h3><a name="advantages"></a>What will be the main advantages of processing in YV12?</h3>
<ul>
  <li>speed increase:<br>
	That depends entirely on the external plugins whether they will have YV12
	support or not. Speed increases like 25-35 percent are expected. Of course
	there will only be a large speed increase if both your source and target are in
	YV12, for example in DVD to DivX/Xvid conversions.</li>
  <li>no color conversions:<br>
	The colour information doesn't get interpolated (so often) and thus stays
	more realistic.</li>
</ul>

<p>MPEG-2 encoders such as CCE, Procoder and TMPGEnc can't handle YV12 input
  directly. CCE and Procoder needs YUY2, and TMPGEnc RGB24. This only means that
  the last line of AviSynth must be a <a href="corefilters/convert.htm"> ConvertToYUY2</a>
  (for CCE/Procoder, or <a href="corefilters/convert.htm"> ConvertToRGB24</a>
  for TMPGEnc) call, and that you will not be able to take full advantage of
  YV12 colorspace. Still there are two advantages:</p>

<ol>
  <li>All internal filtering in AviSynth will be faster though (less data to
	filter, better structure to filter, and a very fast conversion from YV12 to
	YUY2), and you will definitely be able to tell the difference between v2.06
	and v2.5.</li>
  <li>If you are making a progressive clip there is another advantage. Putting
	off the YV12->YUY2 conversion until the end of the script allows you to first
	IVTC or Deinterlace to create progressive frames. But the YV12 to YUY2
	conversion for progressive frames maintains more chroma detail than it does
	for interlaced or field-based frames.<br>

	The color conversions:<br>
	CCE: YV12 -> YUY2 -> YV12<br>
	TMPGEnc: YV12 -> RGB24 -> YV12</li>
</ol>

<h3><a name="VirtualDub"></a>How do I use VirtualDub/VirtualDubMod such that
  there are no unnecessary color conversions?</h3>

<p>Just load your avs file in VirtualDub/VirtualdubMod and set the video on
  "Fast recompress". In this mode the process will stay in YV12 (all the
  necessary filtering has to be done in AviSynth itself). Under compression
  select a codec which support YV12, like Xvid, DivX5, RealVideo (provided you
  download the lastest binaries) or 3ivx D4 (provided you download the lastest
  binaries). Note that DivX3/4 also supports YV12, except that PIV users could
  experience crashes when encoding to DivX4 in YV12.<br>

  If you want to preview the video you also need a
  <a href="#error_message">YV12 decompressor.</a>

<h3><a name="internal_filters"></a>Which internal filters support YV12?</h3>

<p>In principal all internal filters support YV12 natively. Which color formats
  the filters support is specified in the documentation.

<h3><a name="external_plugins"></a>Which external plugins support YV12?</h3>

<p>The plugins which are compiled for AviSynth v2.5 are given in
  <a href="externalplugins.htm"> External plugins</a>. New plugins are listed
  in this <a href="http://forum.doom9.org/showthread.php?s=&amp;threadid=84481">sticky</a>.
  Most of them support YV12 (see documentation).

<h3><a name="disadvantages"></a>Are there any disadvantages of processing in YV12?</h3>
<ul>
<li>If source format is not YV12 (analog capture, DV) or final encoding format
  is not YV12, then color format conversion will results in chroma interpolation
  with some quality decreasing.</li>
<li>Filtering of subsampled chroma can result in some chroma broadening
  relatively luminocity pixels, especially for interlaced video.</li>
<li>Because the chroma in interlaced YV12 video occurs on alternating lines, it
  is necessary to use a different upsampling/downsampling method when converting
  between YV12 and YUV 4:2:2 or RGB. This can lead to chroma
  upsampling/downsampling errors if the wrong color space conversion method is
  used on the video.</li>
<li>If YV12 video is stored in an AVI container, there is no metadata to
  indicate whether the video is interlaced or progressive. This means that an
  application or component doing color space conversion has no easy way of
  choosing the correct conversion method (interlaced or progressive). Most color
  space converters assume progressive which can lead to chroma
  upsampling/downsampling errors when interlaced video is processed in such an
  environment.</li>
</ul>

<h3><a name="colorspace"></a>How do I know which colorspace I'm using at a
  given place in my script?</h3>

<p>To see which colorspace you are using at a given place in your script, add:

<pre>Info()&nbsp;</pre>

<p>... and AviSynth will give you much information about colorspace amongst
  other things!

<h3><a name="colors_swapped"></a>The colors are swapped when I load a DivX file
  in AviSynth v2.5?</h3>

<p>This happens due to a bug in old versions of DivX5. Download the latest
  binaries or use &quot;<a href="corefilters/swap.htm">SwapUV</a>(clip)&quot;.
<h3><a name="green_line"></a>I got a green (or colored
line) at the left or at the right of the clip, how do I get rid of it?</h3>
<p>Your decoder is probably borked, try a ConvertToRGB() at the end of your
script just to be sure and check whether the line has disappeared. Some
application have trouble displaying YV12 clips where the width or height is not
a multiple of 16.</p>
<p>There are several solutions to this problem:</p>
<ul>
  <li>Try having the codec decode to RGB or YUY2 (using
    pixel_type=&quot;...&quot; argument in <a href="corefilters/avisource.htm">AviSource</a>
    or <a href="corefilters/directshowsource">DirectShowSource</a>).</li>
  <li>Use a codec that correctly decodes YV12 clips where the width or height is
    not a multiple of 16.</li>
</ul>

<h3><a name="error_message"></a>I installed AviSynth v2.5 and get the following
  error message: "Couldn't locate decompressor for format 'YV12' (unknown)."?</h3>

<p>Install a codec which supports YV12. DivX5 or one of the recent
  <a href="http://www.xvid.org/">XviD builds</a> or
  <a href="http://forum.doom9.org/showthread.php?s=&threadid=56972">Helix YUV codec</a>
  or some other (ffvfw, ffdshow).  If that still doesn't work, modify your
  registry as explained in the next question.</p>

<h3><a name="black_screen"></a>I installed AviSynth v2.5 and DivX5 (or one of
  the latest Xvid builds of Koepi), all I got is a black screen when opening my
  avs in VirtualDub/VirtualDubMod/MPEG-2 encoder?</h3>

<p>Ok, apparently your video is not decompressed by DivX 5.02 (or Xvid).  Try
  to use <a href="http://members.chello.nl/~p.bekke/">VCSwap utility</a> for hot
  swapping video codecs. 

<p>Advanced user can also do it by hand. Go to your windows-dir and rename a
  file called MSYUV.DLL, or add the following to your registry file:

<pre>REGEDIT4&nbsp;

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Drivers32]&nbsp;
&quot;VIDC.YV12&quot;=&quot;divx.dll&quot;</pre>

<p>Replace "divx.dll" by "xvid.dll" for xvid v0.9 or "xvidvfw.dll" for xvid v1.0.

<h3><a name="YV12_codecs"></a>Are there any lossless YV12 codecs, which I can
  use for capturing for example?</h3>

<p>Capturing in YV12 is not recommended due to issues
of interlacing and chroma; YUY2 will generally pose fewer problems. A lossless
YV12 codec is more useful for saving intermediate files before a multi-pass
encode, to avoid having to run a CPU-intensive script several times. There
are several lossless YV12 codecs:
<ul>
  <li><a href="http://forum.doom9.org/showthread.php?s=&amp;threadid=53305">VBLE
    Codec (by MarcFD)</a>: A huffyuv based encoder
	[<a href="http://forum.doom9.org/showthread.php?s=&amp;threadid=38389&amp;pagenumber=5">discussion</a>].</li>
  <li><a href="http://forum.doom9.org/showthread.php?s=&amp;threadid=50363">LocoCodec
    (by TheRealMoh)</a>: see also
	<a href="http://forum.doom9.org/showthread.php?s=&amp;threadid=53305">here</a>.</li>
  <li><a href="http://www.free-codecs.com/ffvfw_download.htm">ffvfw codec</a> -
	has various modes, in particular HuffYUV yv12.</li>
  <li><a href="http://lags.leetcode.net/codec.html">Lagarith codec (by Ben
	Greenwood)</a> - better compression than Huffyuv but slower.</li>
</ul>

<h3><a name="links"></a>Some important links:</h3>
<ul>
  <li><a href="http://www.fourcc.org/fccyuv.htm#YV12">Technical explanation of
	YV12 (and similar formats)</a></li>
  <li><a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnwmt/html/yuvformats.asp">Good
	Microsoft page on YUV</a></li>
  <li><a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/Display_d/hh/Display_d/dxvaguide_00174d47-49a2-4c28-b67e-ce5a0a58e8ae.xml.asp">4:2:0
	Video Pixel Formats</a>
</ul>
<p>|<a href="faq_sections.htm" title="AviSynth FAQ">
Main Page</a> | <a href="faq_general_info.htm">General
Info</a> | <a href="faq_loading_clips.htm" title="FAQ loading clips">Loading
Clips</a> | <a href="faq_frameserving.htm" title="FAQ frameserving">Loading
Scripts</a> | <a href="faq_common_errors.htm" title="FAQ common errors">Common
Error Messages</a> | <a href="faq_different_types_content.htm" title="FAQ different types content">Processing
Different Content</a> | <b>Dealing
with YV12</b> | <a href="faq_using_virtualdub_plugins.htm" title="FAQ using virtualdub plugins">Processing
with Virtualdub Plugins</a> |
<p><kbd>$Date: 2009/09/12 20:57:20 $</kbd>
</body>
</html>
